<?php

namespace app\common\validate\Business;

// 引入TP的验证器
use think\Validate;

/**
 * 客户验证器
 */
class Business extends Validate
{
    // 验证规则
    protected $rule = [
        // 设置手机号的验证规则 3个规则
        'mobile' => ['require','regex:/^1[3456789]{1}\d{9}$/','unique:business'],
        'password' => 'require',
        'salt' => 'require',
        'gender' => 'number|in:0,1,2', // 性别
        'deal' => 'number|in:0,1', //成交状态
        'status' => 'number|in:0,1', // 邮箱认证状态
        'email' => 'regex:/^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{2,4}$/',  // 邮箱验证规则
    ];

    // 提示文案
    protected $message = [
        'mobile.require' => '手机号必填',
        'mobile.unique' =>'手机号已存在',
        'mobile.regex' =>'手机号格式有误',
        'password.require' => '密码必填',
        'salt.require' => '生成密码盐有误',
        'gender.number' => '性别必须得是个数字',
        'gender.in' => '性别选择有误',
        'status.in' => '邮箱的认证状态有误',
        'email.regex' => '邮箱格式有误',
    ];

    // 验证场景
    protected $scene = [
        // 使用该场景 意味着 只会验证 这两个字段
        'ShopProfile' => ['gender', 'email'],
        'Privatesea' => ['mobile', 'gender']
    ];
}